package com.vivo.yc;

import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.Test;

import java.sql.*;

public class testmy {

    public static void main(String[] args){
        System.out.print("ddd");
    }
    @Test
    public void test(){
        try {
            findpersion(10);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Before
    public void test2(){

    }

    @After
    public void test3(){
        System.out.print("test2_After");
    }

    public void findpersion(int uid) throws ClassNotFoundException, SQLException {
        //1.注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        //2.获取连接
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/yc01","root","123456");
        //3.创建执行sql语句的对象
        Statement statement = conn.createStatement();
        //4.创建sql语句
        String sql = "select *from user where uid>"+uid;

        ResultSet result =  statement.executeQuery(sql);

        if(result.next()){
            System.out.print("查到了");
        }else{
            System.out.print("没查到..");
        }

        result.close();
        statement.close();
        conn.close();
    }

}
